# coding:utf-8

import configparser
import os
from mac import Mac
from Mes import Mes
# 用os模块来读取

cfgpath = "info.ini" # 读取到本机的配置文件
# 调用读取配置模块中的类
conf = configparser.ConfigParser()
conf.read(cfgpath, encoding="utf-8")

basegpath = "baseSet.ini" # 读取到本机的配置文件
# 调用读取配置模块中的类
base = configparser.ConfigParser()
base.read(basegpath, encoding="utf-8")

# 调用get方法，然后获取配置的数据
def getMac():
    mac = Mac()
    if conf.has_section('MES'):
        items = conf.items('MAC')
        print(items)  # list里面对象是元祖
        for c in items:
            f = setattr(mac, c[0], c[1])
    return mac

def getMes():
    mes = Mes()
    if base.has_section('MES'):
        items = base.items('MES')
        print(items)  # list里面对象是元祖
        for c in items:
            f = setattr(mes, c[0], c[1])
    return mes

def needLogin():
    if conf.has_option("INFO", "need_login"):
        if conf.get("INFO", "need_login") == "0":
            return  True
        return  False
    else:
        print("don have")
        return True



if __name__ == "__main__":
    needLogin()

